package com.zxtc.wh.service.appVersion;

import com.zxtc.wh.pojo.appVersion.AppUpdateVesionConstant.*;
import com.zxtc.wh.servlet.appVersion.AppUploadVersionBean;
import com.zxtc.wh.pojo.appVersion.AppVersionBean;
import com.zxtc.wh.pojo.appVersion.UpdateVersionHandleBean;

/**
 * 升级应用版本的服务接口
 */
public interface IAppUpdateVersionService {

    /**
     * 从外部录入一个新版本的，添加到版本库中
     */
    void insert(AppVersionBean version);

    /**
     * 将用户输入的数据解析为服务器需要的格式
     *
     * @param uploadBean 用户的输入
     * @return
     */
    AppVersionBean map(AppUploadVersionBean uploadBean);


    default UpdateVersionHandleBean updateVersionHandle(String resourceType, String downloadType, String restartType, String installType) {
        UpdateVersionHandleBean handleBean = new UpdateVersionHandleBean();
        handleBean.downloadType = ResourceType.getValue(resourceType);
        handleBean.downloadType = DownloadType.getValue(downloadType);
        handleBean.restartType = RestartType.getValue(restartType);
        handleBean.installType = InstallType.getValue(installType);

        return handleBean;
    }
}
